package com.sen.rbac.feign.fallback;

import com.sen.common.common.bo.SysAccountBO;
import com.sen.common.common.response.MessageResult;
import com.sen.common.common.response.ResultMsgEnum;
import com.sen.rbac.dto.SysAccountDto;
import com.sen.rbac.feign.RbacAccountFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @author esjiang
 */
@Slf4j
@Component
public class RbacAccountFeignFallbackFactory implements FallbackFactory<RbacAccountFeign> {

    @Override
    public RbacAccountFeign create(Throwable throwable) {
        return new RbacAccountFeign() {
            @Override
            public MessageResult<SysAccountBO> selectAccountByUserNameForGateway(String userName, String tenantCode, String systemCode) {
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

            @Override
            public MessageResult add(SysAccountDto accountDto) {
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

            @Override
            public MessageResult checkUniqueAccount(@RequestParam("userName") String userName){
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

            @Override
            public MessageResult delete(@RequestParam("userName") String userName) {
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

            @Override
            public MessageResult list(@RequestBody SysAccountDto accountDto)  {
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

            @Override
            public  MessageResult<SysAccountBO> selectAccountByUserName(String userName){
                return MessageResult.reqFailed(ResultMsgEnum.SERVICE_EXCEPTION);
            }

        };
    }
}
